import Vue from 'vue'
import {
  Button,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  Popover,
  Tooltip,
  Scrollbar,
  Link,
  Message,
  Notification,
  Pagination,
  Dialog,
  Input,
  Select,
  Option,
  Table,
  TableColumn,
  Form,
  FormItem,
  Tabs,
  TabPane,
  Tree,
  Icon,
  Loading,
  Popconfirm,
  Row,
  Col,
  Switch,
  Tag,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Checkbox,
  CheckboxGroup,
  Radio,
  RadioGroup,
  InputNumber,
  MessageBox,
  Breadcrumb,
  BreadcrumbItem,
  Rate,
  PageHeader,
  DatePicker,
  Cascader,
  Upload,
  Drawer,
  Image
} from 'element-ui'

Vue.use(Button)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItem)
Vue.use(MenuItemGroup)
Vue.use(Popover)
Vue.use(Tooltip)
Vue.use(Scrollbar)
Vue.use(Link)
Vue.use(Pagination)
Vue.use(Dialog)
Vue.use(Input)
Vue.use(Select)
Vue.use(Option)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Tabs)
Vue.use(TabPane)
Vue.use(Tree)
Vue.use(Icon)
Vue.use(Loading)
Vue.use(Popconfirm)
Vue.use(Row)
Vue.use(Col)
Vue.use(Switch)
Vue.use(Tag)
Vue.use(Dropdown)
Vue.use(DropdownItem)
Vue.use(DropdownMenu)
Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(InputNumber)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Rate)
Vue.use(PageHeader)
Vue.use(DatePicker)
Vue.use(Cascader)
Vue.use(Upload)
Vue.use(Drawer)
Vue.use(Image)

// 将 Message 挂载到vue原型链，使全局都能访问
// Message 消息提示二次封装
Vue.prototype.$message = {
  success: (message, duration = 2000, showClose = false) => {
    return Message({
      type: 'success',
      message: message,
      duration: duration,
      showClose: showClose
    })
  },
  warning: (message, duration = 2000, showClose = false) => {
    return Message({
      type: 'warning',
      message: message,
      duration: duration,
      showClose: showClose
    })
  },
  info: (message, duration = 2000, showClose = false) => {
    return Message({
      type: 'info',
      message: message,
      duration: duration,
      showClose: showClose
    })
  },
  error: (message, duration = 2000, showClose = false) => {
    return Message({
      type: 'error',
      message: message,
      duration: duration,
      showClose: showClose
    })
  }
}

// Notification 通知
Vue.prototype.$notify = {
  success: (message, title = '成功', duration = 2000, showClose = false) => {
    return Notification({
      type: 'success',
      message: message,
      title: title,
      duration: duration,
      showClose: showClose
    })
  },
  warning: (message, title = '警告', duration = 2000, showClose = false) => {
    return Notification({
      type: 'warning',
      message: message,
      title: title,
      duration: duration,
      showClose: showClose
    })
  },
  info: (message, title = '信息', duration = 2000, showClose = false) => {
    return Notification({
      type: 'info',
      message: message,
      title: title,
      duration: duration,
      showClose: showClose
    })
  },
  error: (message, title = '错误', duration = 2000, showClose = false) => {
    return Notification({
      type: 'error',
      message: message,
      title: title,
      duration: duration,
      showClose: showClose
    })
  },
}

Vue.prototype.$confirm = MessageBox.confirm;